<?php
include_once "../header1.php";
?>
<?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   
   else
   {
   ?>
</head>
<body>
<?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?> 
<div id="content">
	<div id="main">
	  <div id="bodyfield">
<div id="lefttablereg">
<table width="978" height="308" class="tablefontv">
<tr>
  <td>&nbsp;</td>
  <td height="18">&nbsp;</td>
  <td></td>
  <td width="585" rowspan="3">
 </td>
</tr>
<tr>
  <td width="6">&nbsp;</td>
<td width="359" height="154"><h3>A resource is a source or supply from which an organization gains profit. Typically resources are materials or other assets that are transformed to produce benefit and in the process may be consumed or made unavailable.The details of resources of Computer labs in our provincial schools are handled by this page...</h3>
 </td>
<td width="8"></td>
</tr>
<td width="6" height="123">&nbsp;</td>
<td>&nbsp;
 </td>
<td width="8"></td>
</table>
  </div><div id="righttablereg">
  <?php
  $L_Ids="";
   $all_labs=mysql_query("SELECT * FROM lab");
  while($a_labs=mysql_fetch_array($all_labs))
  {
	$School_Id=$a_labs['School_Id'];
	$Lab_Id=$a_labs['Lab_Id'];
		 $che_labs=mysql_query("SELECT * FROM resource_details WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	 if(!$che_labs||mysql_num_rows($che_labs)==0)
	 {
		if(empty($L_Ids))
		{
			$S_L_Ids=$School_Id;
			$L_Ids=$Lab_Id;
		}
		else
		{
		$exist="No";
		$All_L_Ids=explode(",",$L_Ids);
		$All_S_Ids=explode(",",$S_L_Ids);
		for($i=0;$i<count($All_L_Ids);$i++)
		{
		if($School_Id==$All_S_Ids[$i]&&$Lab_Id==$All_L_Ids[$i])
		{
		$exist="Yes";
		break;
		}
		}
		if($exist=="No")
		{
		    $S_L_Ids=$S_L_Ids.",".$School_Id;
			$L_Ids=$L_Ids.",".$Lab_Id;
			}
		}
	 }
  }
  
    if($L_Ids!="")
  {  
 $La_Ids=explode(",",$L_Ids);
$Sc_Ids=explode(",",$S_L_Ids);
if($_SESSION['Access_Type']=="Teacher in Charge")
	   {
	    $want="";
	   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
   }
  
   for($j=0;$j<count($Sc_Ids);$j++)
   {
   if($Sc_Ids[$j]==$Own_School_Id)
   {
   $want="Yes";
   break;
   }
   }
     if($want=="Yes")
	   {
echo '<table border="1" class="tablefontv">';
  echo '<tr bgcolor="#333333"><td><font color="white">Lab Id</font></td><td><font color="white">School Id</font></td><td></td></tr>';
  for($i=0;$i<count($La_Ids);$i++)
  {
	  if(is_int($i/2))
    {
   $color="#999999";
    }
	else
	{
   $color="#CCCCCC";
    }
	$Sch_Id=$Sc_Ids[$i];
	$Lab_Id=$La_Ids[$i];
	  $get_sch=mysql_query("SELECT * FROM lab WHERE School_Id='$Sch_Id' AND Lab_Id='$Lab_Id'");
	   if($get_sch_row=mysql_fetch_array($get_sch))
	   {	    
	   if($get_sch_row['School_Id']==$Own_School_Id)
	   {
	   echo '<tr bgcolor="'.$color.'"><td>'.$get_sch_row['Lab_Id'].'</td><td>'.$get_sch_row['School_Id'].'</td><td><a href="RegRes.php?School_Id='.$get_sch_row['School_Id'].'&Lab_Id='.$get_sch_row['Lab_Id'].'">Edit</a></td></tr>';
	  }	  
	}     	      
  }
  echo '</table>';  
  }
  if($want!="Yes")
	   {
	   ?>
   <img src="<?php echo "$basedir";?>/images/images_1.jpg" width="550" height="240" alt="Resource" style="border: solid 1px #D6E0E2; box-shadow: inset 0px 0px 0px 1px #fff; border: 0; -webkit-box-shadow:	inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -moz-box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px;"/>
  <?php
	   }
  }
  else if($_SESSION['Access_Type']=="Administrator")
	   {
echo '<table border="1" class="tablefontv">';
  echo '<tr bgcolor="#333333"><td><font color="white">Lab Id</font></td><td><font color="white">School Id</font></td><td></td></tr>';
  for($i=0;$i<count($La_Ids);$i++)
  {
	  if(is_int($i/2))
    {
   $color="#999999";
    }
	else
	{
   $color="#CCCCCC";
    }
	$Sch_Id=$Sc_Ids[$i];
	$Lab_Id=$La_Ids[$i];
	  $get_sch=mysql_query("SELECT * FROM lab WHERE School_Id='$Sch_Id' AND Lab_Id='$Lab_Id'");
	   if($get_sch_row=mysql_fetch_array($get_sch))
	   { 
	   	   echo '<tr bgcolor="'.$color.'"><td>'.$get_sch_row['Lab_Id'].'</td><td>'.$get_sch_row['School_Id'].'</td><td><a href="RegRes.php?School_Id='.$get_sch_row['School_Id'].'&Lab_Id='.$get_sch_row['Lab_Id'].'">Edit</a></td></tr>';
	  }     	      
  }
		 echo '</table>';  
}	
}	 
 if($L_Ids==""||$_SESSION['Access_Type']=="Teacher")
  {
   ?>
   <img src="<?php echo "$basedir";?>/images/images_1.jpg" width="550" height="240" alt="Resource" style="border: solid 1px #D6E0E2; box-shadow: inset 0px 0px 0px 1px #fff; border: 0; -webkit-box-shadow:	inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -moz-box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); box-shadow: inset 0px 1px 0px #fff, 0px 1px 1px rgba(0,0,0,.15); -webkit-border-radius:4px; -moz-border-radius:4px; border-radius:4px;"/>
  <?php
  }
  ?>
</div>
</div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">RESOURCES</h2>
            </div>
<?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
}
?>

</body>
</html>